package com.zzs.covid19_view.controller;

import com.zzs.covid19_view.common.utils.DateUtil;
import com.zzs.covid19_view.service.DataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;

/**
 * 文件名: SchedulingController
 * 创建者: zzs
 * 创建时间: 2021/8/12 9:39
 * 描述: 定时任务controller
 */
@Controller
@Slf4j
public class SchedulingController {
    @Autowired
    private DataService dataService;

    @Scheduled(cron = "0 0 1 * * ?") //每天凌晨1点执行一次
//    @Scheduled(cron = "0 */1 * * * ?") //每隔1分钟执行一次
    public void schedulingUpdateData(){
        log.info("定时任务执行时间是:"+ DateUtil.getTime());
        dataService.getInformation();
    }
}
